package listdata;

import java.util.ArrayList;
import java.util.List;

import model.CustInfo;
import model.Customer;

public class ListData {

	public static List<Customer> fillCustomerList(){
		List<Customer> customerList = new ArrayList<Customer>();
		customerList.add(new Customer(1, "nanda", "ceria"));
		customerList.add(new Customer(2, "dimas", "group"));
		customerList.add(new Customer(3, "peggy", "mulyawan"));
		customerList.add(new Customer(4, "febri", "iped"));
		customerList.add(new Customer(5, "putra", "solusi"));
		customerList.add(new Customer(6, "fitri", "salim"));
		customerList.add(new Customer(7, "herman", "suhe"));
		return customerList;
	}
		
	public static Customer getCustomerById(long id){
		List<Customer> customerList = fillCustomerList();
		for (Customer customer : customerList) {
			if(customer.getId() == id){
				return customer;
			}
		}
		return null;
	}
	
	public static List<CustInfo> fillCustInfoList(){
		List<CustInfo> list = new ArrayList<CustInfo>();
		list.add(new CustInfo(1, getCustomerById(1), "11"));
		list.add(new CustInfo(2, getCustomerById(1), "21"));
		list.add(new CustInfo(3, getCustomerById(2), "32"));
		list.add(new CustInfo(4, getCustomerById(2), "42"));
		list.add(new CustInfo(5, getCustomerById(3), "53"));
		list.add(new CustInfo(6, getCustomerById(3), "63"));
		list.add(new CustInfo(7, getCustomerById(4), "74"));
		list.add(new CustInfo(8, getCustomerById(4), "84"));
		list.add(new CustInfo(9, getCustomerById(5), "95"));
		list.add(new CustInfo(10, getCustomerById(5), "105"));
		list.add(new CustInfo(11, getCustomerById(6), "116"));
		list.add(new CustInfo(12, getCustomerById(6), "126"));
		list.add(new CustInfo(13, getCustomerById(7), "137"));
		list.add(new CustInfo(14, getCustomerById(7), "147"));
		return list;
	}
	
	public static List<CustInfo> getCustInfoByCustId(long custId){
		List<CustInfo> custInfoListByCustId = new ArrayList<CustInfo>();
		List<CustInfo> allCustInfo = fillCustInfoList();
		for (CustInfo custInfo : allCustInfo) {
			if(custInfo.getCustomer().getId() == custId)
				custInfoListByCustId.add(custInfo);
		}
		return custInfoListByCustId;
	}
	
//	public static void main(String[] args){
//		for (CustInfo custInfo : getCustInfoByCustId(1)){
//			System.out.println("custinfo : "+custInfo.getId()+" -- custId : "+custInfo.getCustomer().getFirstName());
//		}
//	}
}
